package com.mine;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.BeanFactoryAware;
import org.springframework.beans.factory.BeanNameAware;
import org.springframework.beans.factory.DisposableBean;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;

/**
 * @version 1.0.0
 * @since 2022/03/16 08:50
 */
@Component(value = "myCar")
public class Car implements BeanNameAware, BeanFactoryAware, InitializingBean,
    DisposableBean {
//  public Car() {
//    System.out.println("constructing");
//  }

  @PostConstruct
  public void postConstruct() {
    System.out.println("postConstruct");
  }

  @Override
  public void afterPropertiesSet() {
    System.out.println("afterPropertiesSet");
  }

  @PreDestroy
  public void preDestroy() {
    System.out.println("preDestroy");
  }

  @Override
  public void setBeanFactory(BeanFactory beanFactory) throws BeansException {
    System.out.println("setBeanFactory");
  }

  @Override
  public void setBeanName(String s) {
    System.out.println("setBeanName:" + s);
  }

  @Override
  public void destroy() throws Exception {
    System.out.println("destroy");
  }
}
